const express = require('express')
const router = express.Router()
const { search,downLink,songData } = require('../api')

router.get('/', async function (req, res, next) {
  let data = await songData()
  res.send(data)
});



router.get('/songData', async function (req, res, next) {
  let songName = req.query.songName
  // console.log(songName);
  if (songName) {
    let data = await search(songName)
    res.json(data)
  } else {
    res.json({
      "msg":'请输入歌名'
    })
  }
});


router.get('/down', async function (req, res, next) {
  let {id, hash} = req.query
  console.log(id, hash);
  let {data} = await downLink(id, hash)
  res.send(data)
});




module.exports = router